package com.wpp.concurrent.demo4_wait_notify;

import java.util.Random;

/**
 * @author wpp25
 * @date 2021/6/22 21:54
 * @description：
 */
public class Demo4ConsumerRunnable implements Runnable{


    private Demo4Queue queue;

    private Random  random = new Random();

    public Demo4ConsumerRunnable(Demo4Queue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            String s = queue.get();
            System.out.println("\t\t 消费的数据："+ s);
            try {
                Thread.sleep(random.nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
